{extend name='admin@main'}

{block name="button"}

<button data-load='{:url("start")}' class='layui-btn layui-btn-sm layui-btn-primary'>开始监听</button>

<button data-load='{:url("stop")}' data-confirm="确定要停止主进程监听吗？"
        class='layui-btn layui-btn-sm layui-btn-primary'>停止监听
</button>

<button data-modal="{:url('form')}" class='layui-btn layui-btn-sm'>添加任务</button>
{/block}

{block name="content"}

<div class="think-box-shadow">
    {include file='index/index_search'}
    <table class="layui-table margin-top-15" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
            </th>
            <th class='text-left nowrap'>任务信息</th>
            <th class='text-left nowrap'>任务时间</th>
            <th class='text-left nowrap'>任务状态</th>
            <th class='text-left nowrap'>操作</th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='list-table-check-td think-checkbox'>
                <input class="list-check-box" value='{$vo.id}' type='checkbox'>
            </td>
            <td class='text-left nowrap'>
                任务名称：{$vo.name}<br>
                <span class="color-desc">任务指令：{$vo.command}</span>
                <br>
                <span class="color-desc">间隔时间：{$vo.interval_time}秒</span>
            </td>
            <td class='text-left nowrap'>
                {if $vo.end_at&&$vo.start_at}
                执行时间：{$vo.start_at|format_datetime}（ 耗时 <b class="color-blue">{:sprintf("%.4f",strtotime($vo.end_at)-strtotime($vo.start_at))}</b>
                秒 ）<br>
                {else} 创建时间：{$vo.create_at|format_datetime} <br>{/if}
                下次执行时间：{$vo.next_run_time|format_datetime}

            </td>
            <td class='text-left nowrap'>
                <div>
                    {eq name='vo.status' value='2'}
                    <span class="layui-badge layui-bg-black margin-right-5">禁用</span>
                    {elseif $vo.status eq 1}
                    <span class="layui-badge layui-bg-green margin-right-5">正常</span>
                    {/eq}

                </div>
                <div class="color-desc">{$vo.desc|raw|default="没有获取到状态描述"}</div>
            </td>
            <td class='text-left nowrap'>
                <button data-open="{:url('log')}?id={$vo.id}" class='layui-btn layui-btn-sm'>日志</button>
                {eq name='vo.status' value='2'}
                <a class="layui-btn layui-btn-sm  layui-bg-green" data-tips-text="启用该任务" data-action="{:url('run')}"
                   data-value="id#{$vo.id}">
                    启用
                </a>
                {elseif $vo.status eq 1}
                <a class="layui-btn layui-btn-sm layui-bg-black"  data-tips-text="禁用该任务" data-action="{:url('forbid')}"
                   data-value="id#{$vo.id}">
                    禁用
                </a>
                {/eq}
                <a class="layui-btn layui-btn-sm ayui-bg-green" data-confirm="确定要重置该任务吗？"
                   data-action="{:url('redo')}?id={$vo.id}" data-value="id#{$vo.id}">重 置</a>
                <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该记录吗？"
                   data-action="{:url('remove')}?id={$vo.id}" data-value="id#{$vo.id}">删 除</a>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>
{/block}
